clear all
set more off

cd "~/Dropbox/Interest Groups and Nominations/New Data Files"

use "nom_data_for_mobilizaton_regressions_in_STATA.dta", clear
drop if nominee=="bork"  /*exclude Bork since outlier */
gen post_period = (year >= 1970) /* | nominee=="haynsworth")*/
gen quality_post_period = quality*post_period
gen extremity_post_period = extremity*post_period

*ALL years
eststo all_nb1: nbreg total_groups total_groups_lag1 time_diff1 quality time extremity  log_amicus  ///
	total_lag_inter, nolog
	
*Pre 1970
eststo all_nb2: nbreg total_groups total_groups_lag1 time_diff1 quality time extremity log_amicus  ///
	total_lag_inter if post_period==0, nolog
	
*Post 1970
eststo all_nb3: nbreg total_groups total_groups_lag1 time_diff1 quality time extremity log_amicus  ///
	total_lag_inter if post_period==1, nolog
	
*full interactive model
eststo all_nb4: nbreg total_groups total_groups_lag1 time_diff1 quality time  extremity ///
	total_lag_inter  quality_time extremity_time log_amicus , nolog
	
**predictions from time interaction model
*create dummy DV to help with names coding in r
gen foo_dv_total = total_groups

postsim, saving(negbin_sims1_full_time_model_all_groups_new_rr, replace ) reps(1000) seed(101) : /// 
nbreg foo_dv_total total_groups_lag1 time_diff1 quality time extremity  log_amicus    ///
	total_lag_inter  quality_time extremity_time, nolog  

label variable total_groups_lag1  "Lagged total groups"
label variable neg_groups_lag1  "Lagged opposing groups"
label variable quality   "Quality"
label variable  extremity  "Extremity"
label variable time   "Time"
label variable time_diff1   "Time difference"
label variable  log_amicus   "Amicus briefs"
label variable total_lag_inter  "Lag $\times$ time difference"
label variable neg_lag_inter  "Lag $\times$ time difference"
label variable  extremity_time  "Extremity $\times$ time"
label variable  quality_time  "Quality $\times$ time"
	
esttab all_nb1 all_nb2 all_nb3 all_nb4 using  "~/Dropbox/Interest Groups and Nominations/New Paper Files/mobilization_regressions_all_groups_rr.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)  label star(+ 0.10 * 0.05) ///
	order( _cons quality extremity log_amicus time time_diff1 total_groups_lag1 total_lag_inter extremity_time quality_time ) /// 
	title(Mobilization regressions\label{MobilRegressionsAllGroups})

*******************
*REPLICATE USING OPPOSING GROUPS AS DV

*ALL years
eststo opp_nb1: nbreg neg_groups neg_groups_lag1 time_diff1 quality time extremity log_amicus ///
	neg_lag_inter, nolog
*pre 1970
eststo opp_nb2: nbreg neg_groups neg_groups_lag1 time_diff1 quality time extremity log_amicus ///
	neg_lag_inter if post_period==0, nolog
*Post 1970
eststo opp_nb3:  nbreg  neg_groups neg_groups_lag1 time_diff1 quality time extremity log_amicus ///
	neg_lag_inter if post_period==1, nolog
	
*full interactive model
eststo opp_nb4: nbreg neg_groups neg_groups_lag1 time_diff1 quality time  extremity ///
	neg_lag_inter  quality_time extremity_time log_amicus , nolog
**predictions from time interaction model
*create dummy DV to help with names coding in r
gen foo_dv_neg = neg_groups

postsim, saving(negbin_sims1_full_time_model_neg_groups_new_rr, replace) seed(100) reps(1000): /// 
nbreg foo_dv_neg neg_groups_lag1 time_diff1 quality time extremity ///
	neg_lag_inter  quality_time extremity_time log_amicus  , nolog
	
esttab  opp_nb1  opp_nb2  opp_nb3  opp_nb4 using  "~/Dropbox/Interest Groups and Nominations/New Paper Files/mobilization_regressions_opposing_groups_rr.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex) star(+ 0.10 * 0.05) label ///
	order( _cons quality extremity log_amicus time time_diff1 neg_groups_lag1 neg_lag_inter extremity_time quality_time ) /// 
	title(Mobilization regressions\label{MobilRegressionsOppGroups})
	
save "nom_data_for_postestimation.dta", replace

